﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace FAST
{

    [Serializable()]
    public class FilesHandler: IEquatable<FilesHandler>
    {
        protected const bool IS_FILE = true;
        protected const bool IS_FOLDER = false;

        private bool fileType;

        //Method name : FilesHandler() : N.A for constructors.
        //Parameters  : None.
        //Description : An instance of FilesHandler object which can be reference to its sub-classes (FileHandler or FolderHandler) 
        //Exceptions  :  Invalid Cast Exception: Need to downcast to the correct type
        public FilesHandler()
        {
        }

        public void setFileType(bool type)
        {
            fileType = type;
        }

        //Method name : getFileType() : bool
        //Parameters  : None.
        //Description : Return bool to determine whether it is a FileHandler or FolderHandler.
        //Exceptions  : None
        public bool getFileType()
        {
            return fileType;
        }

        public bool Equals(FilesHandler handler)
        {
            if (this.getFileType() == true && handler.getFileType() == true)
            {
                if (((FileHandler)this).getSubFilePath() == ((FileHandler)handler).getSubFilePath())
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else if (this.getFileType() == false && handler.getFileType() == false)
            {
                if (((FolderHandler)this).getFullFolderPath() == ((FolderHandler)handler).getFullFolderPath())
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }

        }
  
    }
}
